package com.qzct.mapper;

import com.mybatisflex.core.BaseMapper;
import com.qzct.entity.Attractions;
import com.qzct.entity.Cuisines;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.ArrayList;

/**
 *  映射层。
 *
 * @author 闽闽
 * @since 2025-01-11
 */
public interface CuisinesMapper extends BaseMapper<Cuisines> {

    @Select("select max(cuisine_id) from tb_cuisines")
    int getMaxId();

    @Select("select  cuisine_id from tb_cuisines order by like_count desc limit 0,6")
    ArrayList<Integer> getHot();

    @Update("UPDATE tb_cuisines SET like_count = like_count+1 WHERE cuisine_id = #{id}")
    void addlike(@Param("id") Serializable id);

    @Select("SELECT cuisine_id as 'cuisineId',name,description,address," +
            "price,o" +
            "pen_time as 'openTime'," +
            "like_count as 'likeCount'," +
            "comment_count as 'commentCount'," +
            "is_hot as 'isHot'," +
            "is_deleted as 'isDeleted'," +
            "phone_number as 'phoneNumber' from tb_cuisines where is_deleted=0")
    ArrayList<Cuisines> getList();
}
